//
//  FilmdetailView.m
//  UI12豆瓣大项目
//
//  Created by 李奇 on 15/10/31.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "FilmdetailView.h"
#import "UIImageView+WebCache.h"
@implementation FilmdetailView

- (void)dealloc
{
    [_poster release];
    [_plot_simpleLabel release];
    [_actorsLabel release];
    [_release_dateLabel release];
    [_ratingLabel release];
    [_rating_countLabel release];
    [_titleLabel release];
    [_countryLabel release];
    [_genresLabel release];
    [_runtimeLabel release];
    [_countryLabel release];
    [_activity release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self creatView];
    }
    return self;
}

-(void)creatView{
    
    //头像
    self.poster = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 100, 165)];
    [self addSubview:self.poster];
    [_poster release];
    //评分
    self.ratingLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 25, 100, 30)];
    [self addSubview:self.ratingLabel];
    [_ratingLabel release];
    //评论人数
    self.rating_countLabel = [[UILabel alloc] initWithFrame:CGRectMake(220, 25, 100, 30)];
    [self addSubview:self.rating_countLabel];
    [_rating_countLabel release];
    //上映时间
    self.release_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 60, 100, 30)];
    [self addSubview:self.release_dateLabel];
    [self.release_dateLabel release];
    //时间
    self.runtimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 95, 100, 30)];
    [self addSubview:self.runtimeLabel];
    [_runtimeLabel release];
    //分类
    self.genresLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 130, 200, 30)];
    [self addSubview:self.genresLabel];
    [self.genresLabel release];
    //国家
    self.countryLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 165, 200, 30)];
    [self addSubview:self.countryLabel];
    [_countryLabel release];
    //制作人
    UILabel *actors_Head_Label = [[UILabel alloc] initWithFrame:CGRectMake(20, 230, 100, 50)];
    actors_Head_Label.text = @"制作人";
    actors_Head_Label.font = [UIFont systemFontOfSize:20];
    [self addSubview:actors_Head_Label];
    [actors_Head_Label release];
    //制作人信息
    self.actorsLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 260, 325, 100)];
    self.actorsLabel.font = [UIFont systemFontOfSize:15];
    self.actorsLabel.numberOfLines = 0;
    [self addSubview:self.actorsLabel];
    [self.actorsLabel release];
    //电影情节
    self.plot_simpleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 320, 325, 50)];
    self.plot_simpleLabel.text = @"电影情节";
    self.plot_simpleLabel.font = [UIFont systemFontOfSize:20];
    [self addSubview:self.plot_simpleLabel];
    [self.plot_simpleLabel release];
    //电影简介
    self.plot_simpleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 360, 325, 303)];
    self.plot_simpleLabel.numberOfLines = 0;
    self.plot_simpleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.plot_simpleLabel];
    [self.plot_simpleLabel release];
    
}


-(void)setActivity:(Activity *)activity{
    if (_activity != activity) {
        [_activity release];
        _activity = [activity retain];
    }
    self.countryLabel.text = self.activity.film_locations;
    self.plot_simpleLabel.text = self.activity.plot_simple;
    self.titleLabel.text = self.activity.title;
    self.genresLabel.text = self.activity.genres;
    self.runtimeLabel.text = self.activity.runtime;
    
    NSString *ratingCount = [NSString stringWithFormat:@"(%@评论)",self.activity.rating_count];
    self.rating_countLabel.text = ratingCount;
    
    NSString *rating = [NSString stringWithFormat:@"评分:%@",self.activity.rating];
    self.ratingLabel.text = rating;
    
    self.release_dateLabel.text = self.activity.release_date;
    self.actorsLabel.text = self.activity.actors;
    
    NSURL *url = [NSURL URLWithString:self.activity.poster];
    [self.poster sd_setImageWithURL:url placeholderImage: [UIImage imageNamed: @"placeHoderImage"]];
    
}

@end
